<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/layuimini/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">应用名称</label>
        <div class="layui-input-block">
            <input type="text" name="application_name" lay-verify="required" lay-reqtext="应用名称不能为空" placeholder="应用名称" value="{$data['application_name']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">应用状态</label>
        <div class="layui-input-block">
            <input type="radio" name="account_type" value="office" title="公众号" {if $data['account_type'] == 'office'}checked{/if}>
            <input type="radio" name="account_type" value="mini" title="小程序" {if $data['account_type'] == 'mini'}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">应用app_id</label>
        <div class="layui-input-block">
            <input type="text" name="app_id" lay-verify="required" lay-reqtext="应用app_id不能为空" placeholder="应用app_id" value="{$data['app_id']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">应用secret</label>
        <div class="layui-input-block">
            <input type="text" name="secret" lay-verify="required" lay-reqtext="应用secret不能为空" placeholder="应用secret" value="{$data['secret']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">微信支付mch_id</label>
        <div class="layui-input-block">
            <input type="text" name="mch_id" placeholder="微信支付mch_id" value="{$data['mch_id']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">微信支付key</label>
        <div class="layui-input-block">
            <input type="text" name="mch_key" placeholder="微信支付key" value="{$data['mch_key']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">微信支付公钥</label>
        <div class="layui-input-block">
            <input type="text" name="cert_path" placeholder="微信支付公钥" value="{$data['cert_path']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">微信支付私钥</label>
        <div class="layui-input-block">
            <input type="text" name="key_path" placeholder="微信支付私钥" value="{$data['key_path']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">token</label>
        <div class="layui-input-block">
            <input type="text" name="token" placeholder="token" value="{$data['token']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">aes_key</label>
        <div class="layui-input-block">
            <input type="text" name="aes_key" placeholder="aes_key" value="{$data['aes_key']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <input type="hidden" name="id" value="{$data['id']}">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="/static/admin/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "{:url('Application/add')}",
                type: 'post',
                dataType: 'json',
                data:data.field,
                success: function (data) {
                    layer.msg(data.msg);
                    //添加成功
                    if(data['status']){
                        setTimeout(function(){
                            if(window !== parent.window) parent.window.layer.closeAll();
                        }, 1000)
                    }
                },
                error: function (xhr, textstatus, thrown) {
                    return layer.msg('Status:' + xhr.status + '，' + xhr.statusText + '，请稍后再试！');
                }
            });

            return false;
        });

    });
</script>
</body>
</html>